package org.suburban.servlet.staticdata;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.suburban.resource.Queues;
import org.suburban.resource.URLs;
import org.suburban.servlet.XMPPServlet;
import com.google.appengine.api.taskqueue.Queue;
import com.google.appengine.api.taskqueue.QueueFactory;
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.*;
import org.suburban.data.Station;
import org.suburban.data.Direction;
import static org.suburban.data.EntityHelper.*;

/**
 * class to query/update all static data
 * @author Alexey Palamarchuk (slonnik@gmail.com)
 *
 */
@SuppressWarnings("serial")
public class StaticDataServlet extends XMPPServlet {
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		/** first clear previously loaded data*/
		clear(Station.TYPE);
		clear(Direction.TYPE);
		
		/** query to update direction*/
		Queue queue = QueueFactory.getQueue(Queues.STATIC_DATA);
		queue.add(withUrl(URLs.DIRECTIONS));
        
    }
}
